package br.com.center.loja.model;

import java.io.Serializable;

import org.simpleframework.xml.Element;

public class Permission implements Serializable {

	private static final long serialVersionUID = 1L;

	@Element(required=false)
	private Integer code;

	@Element(required=true)
	private String name;
	
	@Element(required=false)
	private String description;
	
	public Permission(String name, String description) {
		super();
		this.name = name;
		this.description = description;
	}

	public Permission() {
		super();
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Permission)) {
			return false;
		}
		Permission other = (Permission) obj;
		if (code == null) {
			if (other.code != null) {
				return false;
			}
		} else if (!code.equals(other.code)) {
			return false;
		}
		return true;
	}
	
	@Override
	public String toString() {
		StringBuilder result = new StringBuilder();
		
		result.append("{ code: ").append(getCode())
		      .append(" name: ").append(getName())
		      .append(" description: ").append(getDescription())
		      .append("}");
		
		return result.toString();
	}

}
